#include "stdafx.h"
#include <boost/test/auto_unit_test.hpp>
#include "bmock_util.hpp"
#include <boost/lambda/lambda.hpp>

namespace bmock {
	static const char  buf1[] = "ABCDEFG";
	static const char *buf2   = buf1;
	static const char  buf3[] = "HIJKLMN";

	BOOST_AUTO_TEST_CASE(test_index_of_found) {
		size_t ind;

		BOOST_CHECK_NO_THROW(ind = index_of(buf1,buf1+sizeof(buf1),boost::lambda::_1 == 'A'));
		BOOST_CHECK_EQUAL(size_t(0), ind);
	}

	BOOST_AUTO_TEST_CASE(test_index_of_not_found) {
		size_t ind;

		BOOST_CHECK_NO_THROW(ind = index_of(buf1,buf1+sizeof(buf1),boost::lambda::_1 == 'H'));
		BOOST_CHECK_EQUAL(sizeof(buf1), ind);
	}

	BOOST_AUTO_TEST_CASE(test_mismatch_at_equal) {
		size_t ind;

		BOOST_CHECK_NO_THROW(ind = mismatch_at(buf1,buf1+sizeof(buf1),buf2));
		BOOST_CHECK_EQUAL(sizeof(buf1),ind);
	}

	BOOST_AUTO_TEST_CASE(test_mismatch_at_not_equal) {
		size_t ind;

		BOOST_CHECK_NO_THROW(ind = mismatch_at(buf1,buf1+sizeof(buf1),buf3));
		BOOST_CHECK_EQUAL(size_t(0),ind);
	}
}